<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!-- 
	
	2013-04-11-11 
	按课程查看课程分组
 -->
<html>
  <head>
    <title>按课程查看课程分组</title>
	<link href="<%=path%>/css/index_css.css" rel="stylesheet" type="text/css" />
	<script src="<%=path%>/js/resizeIframe.js" type="text/javascript"></script>
    <script src="<%=path%>/js/syAjax.js" type="text/javascript"></script>
    <script src="<%=path%>/dwr/engine.js"></script>
	<script src="<%=path%>/dwr/util.js"></script>
	<script src="<%=path%>/dwr/interface/shiyueDwr.js"></script>
	<script type="text/javascript">  
	var objectHIDDENID;
	var orgId;
	function giveParamArr(){
		return document.getElementById(objectHIDDENID).value;
	}


      //显示遮罩
      function displayModuleDiv(){
		document.getElementById("items").style.display = "";	
		resizeIframe();
	}
	
	
	//关闭div
	function closeDIV(){
		document.getElementById("items").style.display = "none";

		
	}
	//年度的下拉列表框 
    function getAllYearCallBack(yearMap) {
    DWRUtil.addOptions("year", yearMap);
    if('${year}'!="")
   	{
   	  document.getElementById('year').value="${year}";
   	}else if('${currentYear}'!="")
   	{
   	  document.getElementById('year').value="${currentYear}";
   	}
    } 
    
    function tdClick(url)
    {
      window.location.href=url;
    }
    function load()
    {
    	shiyueDwr.getAllYear(getAllYearCallBack);
      	resizeIframe();
        new Anim.DD($("items"), $("title"));
		$("items").style.left = "50px";
		$("items").style.top = "100px";
        
    }
    
    function doChooseUser(returnStr){
    	var idStr;
    	if(returnStr==undefined){
			return;
		}
		if(returnStr!=null && returnStr!=""){
			var UserArr = returnStr.substring(0,returnStr.length-1).split(",");
			var UserNameStr="";
			for(var i=0;i<UserArr.length;i++){
				var user=UserArr[i];
				var sonArr=user.split("_");
				if((i+1)%5==0){
					UserNameStr+="&nbsp;&nbsp;"+sonArr[1]+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+"<input name=\"ppp"+orgId+"\" type=\"hidden\" value=\""+sonArr[0]+"\"/><br>";
				}else{
					UserNameStr+="&nbsp;&nbsp;"+sonArr[1]+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+"<input name=\"ppp"+orgId+"\" type=\"hidden\" value=\""+sonArr[0]+"\"/>";	
				}
				idStr+=sonArr[0]+",";
			}
			document.getElementById(objectHIDDENID).value=idStr;
			if(UserNameStr!=""){							
				document.getElementById('div'+orgId).innerHTML=UserNameStr;					
			}else
			{
				document.getElementById('div'+orgId).innerHTML="";
			}
			resizeIframe();	
		}else{
			document.getElementById('div'+orgId).innerHTML="";
		}	
    	closeDIV();
    }
    
	var isEditor=1;	//是否为编辑状态 0：可编辑 1：不可编辑	
	function showModel2(thisOrgId){
	   orgId=thisOrgId;
	   objectHIDDENID="p"+orgId;
		if(document.getElementById('year').value=='${applicationScope.currentYear}'){
			if(isEditor==0){
				if('${applicationScope.currentYear}'==null || '${applicationScope.currentYear}'==''){
					alert('您还为设置当前年度，无法进行分组');
					return;
				}		
				
					document.getElementById("selectUserIframe").src="<%=path%>/toSelectTeacherorganizationAction.action?user.userType=${sessionScope.UserInfo.userType}&years=${applicationScope.currentYear}&role.roleId=member&actionURL=saveUserAndCourseCourseAction.action&t="+new Date();
				
				displayModuleDiv();
				
			}else{
	      	  alert("请设为编辑状态!");
	      	}
      	}else{
      		alert("不是当前年度，不能进行此操作！");
      	}
      }
      
      //改变编辑状态
   	  function changeEditor(a)
   	  {
   	    if(isEditor==0)
   	    {
   	    	a.innerHTML="<font color='#000000'>设为编辑状态</font>";
   	    	isEditor=1;
   	    }else{
   	    	a.innerHTML="<font color='red'>设为非编辑状态</font>";
   	    	isEditor=0;
   	    }
   	  }
   	  
   	function orgList()
    {
    	window.location.href="<%=path%>/findTeaAndDeporganizationAction.action?years=${currentYear}&orgType=2&forwardPage=teaToDepartment";
    }
    
    function teaList()
    {
    	window.location.href="<%=path %>/findUserGradeGradeAndClassAction.action?year=${applicationScope.currentYear }&forwardPage=teaToGrade";
    }
	
	</script>
  </head>
  
  <body onload="load();">
  <div id="contentDIV" style="position:absolute;width:100%; padding:5px; background-color:#ffffff;z-index:1;">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" class="f_5"><c:choose><c:when test="${sessionScope.UserInfo.userType==2}">教师分组</c:when><c:otherwise>学科分组管理</c:otherwise></c:choose></td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#9DD12E"></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="bottom" background="images/sywesp_24.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <c:if test="${sessionScope.UserInfo.userType==2}">
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="images/sywesp_18.gif" class="f_6" style="cursor:pointer;" onclick="orgList();">
                  部门分组
                </td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="5" align="left">&nbsp;</td>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="images/sywesp_18.gif" style="cursor:pointer;"  class="f_6" onclick="teaList();">
                  年级分组
                </td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="5" align="left">&nbsp;</td>
            </c:if>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="images/sywesp_25.gif" class="f_9">学科分组</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table>
            </td>
            <td align="right" class="f_5">
        		&nbsp;
   			</td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left" valign="top" class="tb_8 border_2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="25" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
				  <td width="38%" align="left"><a href="<%=path%>/findCourseGroupByUserCourseAction.action?user.userType=${sessionScope.UserInfo.userType}&years=${applicationScope.currentYear}&forwardPage=UserToCourse">按照人员分组</a> ┆ 按照学科分组<br /></td>                <td width="46%" align="right" valign="top">按年度查询：
                  <label>
                  <select name="select2" id="year" onchange="tdClick('<%=path %>/findCourseGroupByUserCourseAction.action?user.userType=${sessionScope.UserInfo.userType}&forwardPage=courseToUser&years='+this.value);">
                  </select>
                  </label></td>
                <td width="16%" style="border:solid #CCCCCC 1px;" align="right" class="f_4" onclick="changeEditor(this);" style="cursor:pointer;"><font color="#000000">设为编辑状态</font></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td align="left" valign="top">
            <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DCDCDC">
              <tr>
                <td width="9%" height="30" align="center" bgcolor="#DBE9F6" class="f_4" nowrap="nowrap">学科名称</td>
                <td width="91%" align="center" bgcolor="#DBE9F6" class="f_4">姓名</td>
                </tr>
              <c:if test="${! empty AllCourseByStatusAndParent}">
              <c:forEach items="${AllCourseByStatusAndParent}" var="org"><c:set value="" var="totalArr"></c:set>
              <tr>
                <td height="30" align="center" bgcolor="#FFFFFF" class="f_4" nowrap="nowrap">${org.name}
                <c:if test="${! empty UserList}">
                  <td bgcolor="#FFFFFF" align="left" height="25" style="cursor:pointer;" onclick="showModel2('${org.courseId}')" onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''">
                  <div id="div${org.courseId}">
                  <%int i=0; %>
                  <c:forEach items="${UserList}" var="user">
                  <c:if test="${! empty mapList}">
	                <c:set value='${user.userId}${org.courseId}' var="UserOrg"></c:set>
		                <c:if test="${! empty mapList[UserOrg]}">
		                <c:set value="${user.userId},${totalArr}" var="totalArr"></c:set>
		                	<%
		                		i++;
		                		if(i%5==0){
		                	 %>
		                	 	&nbsp;&nbsp;${user.name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="ppp${org.courseId}" type="hidden" value="${user.userId}"/><br>
		                	 <%}else{ %>
		                	 	&nbsp;&nbsp;${user.name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="ppp${org.courseId}" type="hidden" value="${user.userId}"/>
		                	 <%} %>
                		</c:if>	
                  </c:if>
                  </c:forEach>
                  </div>
                  <input type="hidden" id="p${org.courseId }" value="${totalArr}"/>
                  </td>
                </c:if>
                <c:if test="${empty UserList}">
		            <td bgcolor="#FFFFFF" align="center" height="25" style="cursor:pointer;" onclick="showModel2('${org.organizationId}')" onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''">
		            <div id="div${org.organizationId}">
						<font color="red">此学科暂无人员</font><input name="ppp${org.organizationId}" type="hidden" value="${user.userId}"/>
					</div>
					<input type="hidden" id="p${org.organizationId }" value=""/>
		            </td>
		        </c:if>                 
                </tr>
                
                </c:forEach>
                </c:if>
            </table>
            </td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<div id="items" style="position: absolute; width: 730px;height:600px; top:100px; left:200px; padding-bottom:8px; background-color:#ECF7FD;z-index:10; border:3px solid #3A6EA5; display: none;" >
	<div style="width:100%;top:100px;left:200px;" id="title">
		<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center" bgcolor="#3A6EA5">
						<tr style=" height: 30px;">
		<td>&nbsp;&nbsp;<font color='#FFFFFF'>请选择教师</font></td>
		<td align="right"><a href="javascript:closeDIV();" style="text-decoration: none;"><span style="color: #000000; font-size:;">[关闭]</span></a></td>
						</tr>
		</table>
	</div>
	<div style="width:100%;top:100px;left:200px;height: 100%">
	<iframe name="selectUserIframe" id="selectUserIframe" src="" style="width:100%;height: 100%" align="middle"  frameborder="0"></iframe>   
	</div>
		
</div>
  </body>
</html>
